<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">

  </div>
  <script>
    let mixin = {
      data(){
        return {
          name: '张三',
          age: 12,
          obj: {
            username: 'admin',
            password: '123321'
          }
        }
      },
      methods: {
        fun1() {
          console.log('混入方法1');
        }
      },
      created() {
        console.log('混入的Created');
      }
    }
    // 全局混入
    vue.mixin(mixin)
    let vm = new Vue({
      el: '#app',
      // 局部混入
      // mixins: [ mixin ],
      data: {
        name: '李四',
        gender: 'male',
        obj: {
          username: 'manager',
          role: '管理员'
        }
      },
      methods: {
        fun2() {
          console.log('vue实例方法1');
        }
      },
      created() {
        console.log('实例的Created');
      }
    })
  </script>
</body>
</html>